<?php
/**
 * Created by PhpStorm.
 * User: EZ
 * Date: 2017/5/25
 * Time: 14:19
 */
namespace app\index\controller;
class Action
{
    public  $c_path=null;
    public  $a_path=null;
    public  $m_path=null;
    public $data=null;
    public function __construct()
    {
        $this->data=null;
    }


    public function display($view_path=''){
//        foreach($this->data as $k=>$v){
//            ${$k}=$v;
//        }
        extract($this->data);
        if($view_path==''){
            $view_path=$this->a_path;
        }
        $html_file=HTML_PATH.$this->m_path.'/'.$this->c_path.'/'. $view_path.'.html';
//        echo $html_file;die;
        if(!file_exists($html_file)) die("模板不存在".$html_file);
        require $html_file;
    }

    public function assign($key,$val=''){
        if(is_array($key)){
            $this->data=array_merge($this->data,$key);
        }else{
            $this->data[$key]=$val;
        }
    }

    public function _empty(){

        header("HTTP/1.1 404 Not Found");
        echo "该方法不存在";
    }
}